//
//  ZWClipViewController.m
//  MyTest
//
//  Created by rayootech on 15/9/26.
//  Copyright (c) 2015年 rayootech. All rights reserved.
//

#import "ZWClipViewController.h"
#import "UIImage+ZWJieTu.h"
@interface ZWClipViewController ()

@end

@implementation ZWClipViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
     self.title=@"屏幕截图";
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



- (IBAction)clipClick {
    //延迟1.0秒在截图 只需输入dispatch_after 就会显示代码的提示非常的方便
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        //1、捕捉
        UIImage *newImage=[UIImage captureWithView:self.view];
        
        self.bgimagView.image=newImage;
    });
}

- (IBAction)saveToClcik {
    
    //延迟1.0秒在截图 只需输入dispatch_after 就会显示代码的提示非常的方便
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        //1、捕捉
        UIImage *newImage=[UIImage captureWithView:self.view];
        
        //2、写入文件
        NSData *data=UIImagePNGRepresentation(newImage);
        NSString *path=[[NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"new.png"];
        [data writeToFile:path atomically:YES];
        
        _tfdText.text=path;
        
    });
}
@end
